package com.baor.controller;

import com.baor.domain.UserVO;
import com.baor.service.UserService;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baor.util.R;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@RestController
@RequestMapping(value="/userManager")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value="/login")
    public R login(@RequestBody UserVO user){
        return this.userService.login(user);
    }
    /**
     * username String
     * password String
     * avatar String
     * phone String
     * realname String
     * @param user
     * @return
     */
    @PostMapping(value="/addUser")
    public R addUser(@RequestBody UserVO user) {
        return this.userService.insertUser(user);
    }
    @PostMapping(value="/updateUser")
    public R updateUser(@RequestBody UserVO user) {
        return this.userService.updateUser(user);
    }

    @PostMapping(value="/uploadIcon")
    public R uploadIcon(MultipartFile[] files){
        return this.userService.uploadIcon(files);
    }
    @RequestMapping(value = "/userList")
    public R userList(@RequestBody Map<String, Object> params){

        return this.userService.userList(params);
    }

}
